package ufc.si.auditoria.util;

import java.io.IOException;

import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;

public class AESUtil {

	private static byte[] chave = "kkjadfnjafndhsgt".getBytes();
	
	public static byte[] encriptografar(String textoPuro) throws Exception{
		Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
		cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(chave, "AES"));
		return cipher.doFinal(textoPuro.getBytes());
	}

	public static String decriptografar(byte[] textoCifrado) throws Exception{
		Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
		cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(chave, "AES"));
		return new String(cipher.doFinal(textoCifrado));
	}
	
	public static void main(String[] args) {
		
		AESUtil aes = new AESUtil();
		try {
		
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}

}
